<?php
/*
 * 策略模式
 * 在系统中定义算法并以它们自己的类型封装
 * 解释类经常执行非常相似的任务，所以最好仔细检查创建的类是否重复
 */
function my_autoloader($class) {
    //var_dump($class);
    include $class . '.php';
}
spl_autoload_register('my_autoloader');

$markers = array(
    new RegexMarker("/f.ve/"),
    new MatchMarker("five"),
    new MarkLogicMarker('$input equals "five"')
);

foreach($markers as $marker){
    print "\n<BR/><strong>em".get_class($marker)."</strong>: \n<BR/>\n<BR/>";
    $question = new TextQuestion("how many beans make five",$marker);
    foreach(array("five","four") as $response){
        print " response: $response: ";
        if($question->mark($response)){
            print "well done \n<BR/>";
        }else{
            print "never mind \n<BR/>";
        }
    }
}